home *** CD-ROM | disk | FTP | other *** search
/ 9-Digit Zip Code Directory / 9-Digit Zip Code Directory (American Business Information) (ABIZIP-12).ISO / z4src.zip / DCRC.C < prev    next >
C/C++ Source or Header  |  1995-04-26  |  4KB  |  133 lines

  1. //----------------------------------------------------------------------------
  2. //                            MODULE DESCRIPTION
  3. //
  4. //  Module:    dcrc.c
  5. //   Title:    Application Template
  6. //  Notice:    John M. Weeder
  7. //                 Copyright (c) 1993. All rights reserved.
  8. //             This module contains proprietary information and should be 
  9. //                treated as confidential.
  10. //
  11. //----------------------------------------------------------------------------
  12. //                           MAINTENANCE HISTORY
  13. //
  14. // $Workfile$
  15. // $Revision$
  16. //   $Author$
  17. //     $Date$
  18. //      $Log$    
  19. //
  20. //----------------------------------------------------------------------------
  21. //                             MODULE NARRATIVE
  22. //
  23. //    This module contains the program entry point for
  24. //
  25. //    The code in this module may be written in C++ or C.
  26. //
  27. //    This module is portable to:
  28. //        DOS 3.X+
  29. //        MS Windows 3.X+
  30. //        OS/2 2.X+
  31. //        OS/2 2.0 PM
  32. //
  33. //    The following compilers are supported:
  34. //        MSC 6.0A
  35. //        MSC/C++ 7.0
  36. //        Borland C++ 3.1 for DOS
  37. //        Borland C++ 1.0 for OS/2 2.X
  38. //
  39. //----------------------------------------------------------------------------
  40. #include <dio.h>
  41.  
  42.  
  43. //----------------------------------------------------------------------------
  44. //    Stack size
  45. //----------------------------------------------------------------------------
  46. #if COMPILER_BORLAND && (OS_DOS || OS_WINDOWS)
  47. unsigned _stklen = 0x4000;
  48. #endif
  49.  
  50.  
  51. //----------------------------------------------------------------------------
  52. //    Globals
  53. //----------------------------------------------------------------------------
  54.  
  55. //
  56. // A useless string which is simply embedded in the executable.
  57. //
  58. PSZ __pszCredits__ = "Written by John M Weeder, 1993";
  59.  
  60.  
  61. //
  62. //    This should contain a program description which will be displayed as
  63. //    part of the program's help text.
  64. //
  65. static PCSZ pcszDescription =
  66.     "This program calculates the CRC code for a logical data file.";
  67.  
  68. //
  69. //    Program command line options
  70. //
  71. static CHAR szPhysical[MAX_PATH];
  72. static CHAR szLogical[MAX_PATH];
  73. static CHAR szType[MAX_PATH];
  74. static BS_CMDOPT acmdopt[] =
  75.     {
  76.     { "physical",     (PVOID)szPhysical,    CMDOPT_FILESPECR(80), "Physical file."},
  77.     { "logical",     (PVOID)szLogical,        CMDOPT_FILESPECR(80), "Logical file."},
  78.     { "type",         (PVOID)szType,            CMDOPT_FILESPECR(80), "File type."},
  79.     BS_CMDOPT_NULL,
  80.     };
  81.  
  82.  
  83. //----------------------------------------------------------------------------
  84. //   Description:    main() - Program entry point
  85. //    Parameters:    Standard C parameters
  86. //       Returns:    DOS return code.
  87. //----------------------------------------------------------------------------
  88. int main(int argc, char **argv)
  89. {
  90. static BS_CFG cfg = CFG_DFT;
  91.     USHORT i, usType;
  92.     SHORT sResult = 99;
  93.     CRC crc;
  94.  
  95.     //
  96.     //    Initialize base library
  97.     //
  98.     BaseLibraryInitialize(argc, argv, &cfg);
  99.     BaseTitle("$Revision:  93.1  $", __DATE__, __TIME__, "Data File CRC Utility");
  100.     if (!BaseTitleHelp(acmdopt, pcszDescription,0))
  101.         return 99;
  102.  
  103.     for (i = 0; adiotype[i].pszShort; ++i)
  104.         if (stricmp(adiotype[i].pszShort, szType) == 0)
  105.             {
  106.             usType = adiotype[i].usType;
  107.             break;
  108.             }
  109.     if (adiotype[i].pszShort == NULL)
  110.         {
  111.         Error("Invalid file type.");
  112.         Output("\nTypes:\n");
  113.         for (i = 0; adiotype[i].pszShort; ++i)
  114.             Output("  %4s  %s\n", adiotype[i].pszShort, adiotype[i].pszLong);
  115.         return 1;
  116.         }
  117.     DioSetDataPath(EnvGet("DATA"));
  118.     Output("%s '%s'\n", szPhysical, szLogical);
  119.     if (DioCrc(szPhysical, szLogical, usType, &crc))
  120.         {
  121.         Output("CRC = 0x%08lX\n", crc);
  122.         Output("Success.\n");
  123.         sResult = 0;
  124.         }
  125.     else
  126.         Output("Success.\n");
  127.     DioCloseAll();
  128.     return sResult;
  129. }
  130. //----------------------------------------------------------------------------
  131. //------------------------------- End of File --------------------------------
  132. //----------------------------------------------------------------------------
  133.